import { Component } from "react";

export default class Demo2 extends Component {
  // constructor(props) {
  //   super(props)
  //   this.state = {
  //     money: this.props.money + 100
  //   }
  // }
  state = {
    msg: ''
  }
  render() {
    console.log('子组件', 2);
    const { msg } = this.state
    const { car, money, check } = this.props
    return (
      <div>
        <h3>类组件</h3>
        <div>{car}</div>
        <div>{money}</div>
        <div>{check ? '是' : '否'}</div>
        <p>子组件的msg:{msg}</p>
        <input onChange={this.handleChange} value={this.state.msg} type="text" placeholder="输入值" />
        {/* <button onClick={this.btn}>+100</button> */}
      </div>
    )
  }
  // btn = () => {
  //   console.log(this.state.money);
  // }
  handleChange = (e) => {
    this.setState({
      msg: e.target.value
    })
    this.props.fn(e.target.value)
  }
  // shouldComponentUpdate(nextProps) {
  //   return false
  // }
}